<%@page import="util.HttpUtil"%>
<%@page import="utils.*,dicts.*"%>
<%@page import="java.util.*"%>
<%
	String version=request.getParameter("version") ;
	String direct=request.getParameter("direct") ;

	String no=request.getParameter("no") ;
	String key=request.getParameter("key");
	String order=request.getParameter("order") ;
	String site=request.getParameter("site") ;
	String cur=request.getParameter("cur") ;
	String loc=request.getParameter("loc") ;
	String notify=request.getParameter("notify") ;
	String product=request.getParameter("product") ;
	
	String number=request.getParameter("number") ;
	String expire=request.getParameter("expireMonth") +request.getParameter("expireYear");
	String cvv=request.getParameter("cvv") ;
	
	String ip=request.getParameter("ip") ;
	String os=request.getParameter("os") ;
	String browser=request.getParameter("browser") ;
	String finger=request.getParameter("finger") ;
	String locale=request.getParameter("locale") ;
	String timing=request.getParameter("timing") ;
	
	String cfname=request.getParameter("cfname") ;
	String clname=request.getParameter("clname") ;
	String cphone=request.getParameter("cphone") ;
	String cemail=request.getParameter("cemail") ;
	String ccountry=request.getParameter("ccountry") ;
	String cstate=request.getParameter("cstate") ;
	String ccity=request.getParameter("ccity") ;
	String caddr=request.getParameter("caddr") ;
	String czip=request.getParameter("czip") ;
	
	String hfname=request.getParameter("hfname") ;
	String hlname=request.getParameter("hlname");
	String hphone=request.getParameter("hphone") ;
	String hemail=request.getParameter("hemail") ;
	String hcountry=request.getParameter("hcountry") ;
	String hstate=request.getParameter("hstate") ;
	String hcity=request.getParameter("hcity") ;
	String haddr=request.getParameter("haddr") ;
	String hzip=request.getParameter("hzip") ;
	

	
	String signature=DigestUtil.sha256(no+order+cur+loc+key);
	
	number=AesUtil.AES_Encrypt(DigestUtil.md5(key), number);
	expire=AesUtil.AES_Encrypt(DigestUtil.md5(key), expire);
	cvv=AesUtil.AES_Encrypt(DigestUtil.md5(key), cvv);
	
	String path=RealmDict.GATEWAY+"Entrance";
	if(direct.equals("gateway")){
		path=RealmDict.GATEWAY+"Entrance";
	}
	if(direct.equals("portal")){
		path=RealmDict.PORTAL+"Entrance";
	}
	Map map=new HashMap();
	
	map.put("version",version);
	
	map.put("no",no);
	map.put("order",order);
	map.put("site",site);
	map.put("cur",cur);
	map.put("loc",loc);
	map.put("notify",notify);
	map.put("product",product);
	
	map.put("signature",signature);
	
	map.put("ip",ip);
	map.put("os",os);
	map.put("browser",browser);
	map.put("finger",finger);
	map.put("locale",locale);
	map.put("timing",timing);
	
	map.put("cfname",cfname);
	map.put("clname",clname);
	map.put("cphone",cphone);
	map.put("cemail",cemail);
	map.put("ccountry",ccountry);
	map.put("cstate",cstate);
	map.put("ccity",ccity);
	map.put("caddr",caddr);
	map.put("czip",czip);
	
	map.put("hfname",hfname);
	map.put("hlname",hlname);
	map.put("hphone",hphone);
	map.put("hemail",hemail);
	map.put("hcountry",hcountry);
	map.put("hstate",hstate);
	map.put("hcity",hcity);
	map.put("haddr",haddr);
	map.put("hzip",hzip);
	
	map.put("number",number);
	map.put("expire",expire);
	map.put("cvv",cvv);
	String res=new HttpUtil().post(path,map);

%>

<%@ page language="java" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>MOCK</title>
<link href="<%=request.getContextPath()%>/css/global.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="<%=request.getContextPath()%>/js/jquery.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/js/global.js"></script>
<script type="text/javascript" src="<%=request.getContextPath() %>/js/fingerprint2.js"></script>
<script type="text/javascript" src="<%=request.getContextPath() %>/js/jstz.js"></script>

</head>
<body style="background-color: #1c3e57; margin: 10px;">
	<div style="padding: 25px; margin-bottom:10px;border: 1px dotted #ccc; background-color: #fff;">
		<h1><a href="<%=request.getContextPath (  )%>">首页</a> | 提交交易至支付网关并返回支付结果</h1>
	</div>
	<div style="padding: 25px; border: 1px dotted #ccc; background-color: #fff;">
		
		<table border="0" width="100%" >
			<tr>
				<td width="25%"></td>
				<td width="25%"></td>
				<td width="25%"></td>
				<td width="25%"></td>
			</tr>
			<tr>
				<td><hr/></td>
				<td><hr/></td>
				<td><hr/></td>
				<td><hr/></td>
			</tr>
			<tr>
				<td colspan="4">&nbsp;<%=res.replaceAll(",", ",</br>") %></td>
			</tr>
			<tr>
				<td><hr/></td>
				<td><hr/></td>
				<td><hr/></td>
				<td><hr/></td>
			</tr>
			<tr>
				<td colspan="4" align="right">
					<input type="button" class="submit" value="返回首页" onclick="location.href='<%=request.getContextPath()%>'">
			</tr>
		</table>
	</div>
</body>